import 'package:flutter/material.dart';

/// 吸顶，
//  SliverPersistentHeader(
//            pinned: true,
//            delegate: StickyBarDelegate(
//              height: tabBarHeight,
//              child: getTabBar(context),
//            ),
//          )
class StickyBarDelegate extends SliverPersistentHeaderDelegate {
  StickyBarDelegate({@required this.child, this.height = 48});

  final Widget child;
  final double height;

  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return Container(
      color: Colors.white,
      height: height,
      child: child,
    );
  }

  @override
  double get maxExtent => height;

  @override
  double get minExtent => height;

  @override
  bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
    return true;
  }
}
